package input

type AccountResourceVO struct {
	Id   int64   `json:"id"`
	Pid  int64   `json:"pid"`
	Name *string `json:"name"`
	Code *string `json:"code"`
	Type int8    `json:"type"`
	Meta string  `json:"meta"`
}
type ResourceItem struct {
	*AccountResourceVO
	Children []*ResourceItem `json:"children"`
}

// TreeList 树状列表
func TreeList(pid int64, nodes []*AccountResourceVO) (list []*ResourceItem) {
	list = make([]*ResourceItem, 0)
	for _, v := range nodes {
		if v.Pid == pid {
			item := new(ResourceItem)
			item.AccountResourceVO = v
			child := TreeList(v.Id, nodes)
			if len(child) > 0 {
				(*item).Children = child
			}
			list = append(list, item)
		}
	}
	return
}
